<template>
    <div>
        <input type="checkbox" />
        已完成 {{doneCount}} / {{todos.length}} 
        <button >删除选中</button>
    </div>
</template>

<script>
    export default {
        name : "MyFooter",
        props:["todos","updateCheckTodo","deleteTodo"],
        computed:{
            doneCount(){
                // reduce方法详解见 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce
                // accumulator是累计器
                // current是当前对象
                // index是当前索引
                // array是整个数组
                // return this.todos.reduce((accumulator,current, index, array)=>{
                //     return accumulator + (current.done ? 1:0 )
                // },0)
                // 可以精简成
                return this.todos.reduce((count,todo) => count+(todo.done?1:0) ,0 )
            }
        }
    }
</script>

<style scoped>
    
</style>